//
//  FileViewController.m
//  JavaBaas_iOS_SDK
//
//  Created by zhaopeng on 16/1/27.
//  Copyright © 2016年 Buge. All rights reserved.
//

#import "FileViewController.h"
#import "JavaBaas.h"

@implementation FileViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (IBAction)createFile:(UIButton *)sender {
    

}

- (IBAction)upload:(UIButton *)sender {
    
    /**
     *  上传文件首先要创建JBFile 提供了3中方法
     ＊  fileWithData:
     ＊  fileWithName:data:
     *  fileWithURL:
     */
    
//    创建对象
    UIImage *image = [UIImage imageNamed:@"Test"];
    NSData *imageData = UIImagePNGRepresentation(image);
    JBFile *file_1 = [JBFile fileWithData:imageData];
    
//    JBFile *file_2 = [JBFile fileWithName:@"test" data:imageData];
    
    
//    NSString *path = [[NSBundle mainBundle] pathForResource:@"Test@2x.png" ofType:nil];
//    NSURL *url = [NSURL fileURLWithPath:path];
//    JBFile *file_3 = [JBFile fileWithURL:url];
    
//    上传
    [file_1 saveInBackgroundWithBlock:^(id object, NSError *error) {
        if (!error) {
            NSLog(@"%@", file_1.url);
        } else {
            NSLog(@"%@", error);
        }
    } progressBlock:^(float percentDone) {
        NSLog(@"%f", percentDone);
    }];
    
}
@end
